package rsb21411ls.d1202yichang;


public interface Shape {
    double getArea(double r) throws Exception;
}
class Square implements Shape{


    @Override
    public double getArea(double d) throws Exception{
        double area;
        if (d<0){
            throw new Exception("半径不能是负数");
        }
        else {
            area= d*d;
        }return area;

    }
}
class Circle implements Shape{
    double area;


    @Override
    public double getArea(double r) throws Exception{
        if (r<0){
            throw new Exception("半径不能是负数");
        }else {
            area= Math.PI*r*r;
        }return area;
    }
}
